_require local "../../../../basis.smi"
(* _require local "../../../libs/ids/main/LocalID.smi" *)
_require local "../../../data/types/main/TypesBasics.smi"

_require "../../../../smlformat-lib.smi"
_require "../../../data/symbols/main/Loc.smi"
_require "../../../data/types/main/OPrimMap.smi"
(* _require "../../../libs/util/main/TermFormat.smi" *)
_require "../../../compilerIRs/idcalc/main/IDCalc.ppg.smi"
_require "../../../data/types/main/VarMap.smi"
_require "../../../data/types/main/Types.ppg.smi"
_require "../../../compilerIRs/typedcalc/main/TypedCalc.ppg.smi"
_require "../../../data/types/main/TvarMap.smi"

structure TypeInferenceContext =
  struct
    type tvarEnv = Types.ty TvarMap.map
    val format_tvarEnv
        : Types.ty TvarMap.map
          -> SMLFormat.format
    type varEnv = TypedCalc.idstatus VarMap.map
    val format_varEnv
        : varEnv -> SMLFormat.format
    type oprimEnv = Types.oprimInfo OPrimMap.map
    val format_oprimEnv
        : oprimEnv -> SMLFormat.format
    type context = {oprimEnv:oprimEnv, tvarEnv:tvarEnv, varEnv:varEnv}
    val format_context
        : context -> SMLFormat.format
    val emptyContext : context
    val bindVar
        : int * context
          * IDCalc.varInfo
          * TypedCalc.idstatus
          -> context
    val bindOPrim : context * IDCalc.oprimInfo * Types.oprimInfo -> context
    val extendContextWithVarEnv : context * varEnv -> context
    val extendContextWithContext : context * context -> context
    val overrideContextWithTvarEnv : context * tvarEnv -> context
    val addUtvar
        : Types.lambdaDepth
          -> context
          -> (Types.utvar * IDCalc.tvarKind) list
          -> Loc.loc
          -> context * (Types.tvState ref * IDCalc.tvarKind) TvarMap.map
  end
